home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xfig.idb / usr / freeware / src / xfig / transfig.3.1.2 / transfig / sys.c.z / sys.c
Encoding:
C/C++ Source or Header  |  1997-09-09  |  2.2 KB  |  87 lines

  1. /*
  2.  * TransFig: Facility for Translating Fig code
  3.  * Copyright (c) 1985 Supoj Sutantavibul
  4.  * Copyright (c) 1991 Micah Beck
  5.  *
  6.  * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  7.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  8.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  9.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  10.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  11.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  12.  * PERFORMANCE OF THIS SOFTWARE.
  13.  *
  14.  * The X Consortium, and any party obtaining a copy of these files from
  15.  * the X Consortium, directly or indirectly, is granted, free of charge, a
  16.  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
  17.  * nonexclusive right and license to deal in this software and
  18.  * documentation files (the "Software"), including without limitation the
  19.  * rights to use, copy, modify, merge, publish, distribute, sublicense,
  20.  * and/or sell copies of the Software, and to permit persons who receive
  21.  * copies from any such party to do so, with the only requirement being
  22.  * that this copyright notice remain intact.  This license includes without
  23.  * limitation a license to do the foregoing actions under any patents of
  24.  * the party supplying this software to the X Consortium.
  25.  */
  26.  
  27. #include <stdio.h>
  28. #include "transfig.h"
  29.  
  30. #define MAXSYS 10000
  31. static char sysbuf[MAXSYS];
  32.  
  33. char *sysls()
  34. {
  35.   FILE *ls;
  36.   int i;
  37.   char c;
  38.  
  39.   ls = popen("/bin/ls *.fig", "r");
  40.   i = 0;
  41.   c = fgetc(ls);
  42.   while (c != EOF & i < MAXSYS-1)
  43.   {
  44.     sysbuf[i] = c;
  45.     i += 1;
  46.     c = fgetc(ls);
  47.   }
  48.   sysbuf[i] = '\0';
  49.   return sysbuf;
  50. }
  51.  
  52. sysmv(f)
  53. char *f;
  54. {
  55.   sprintf(sysbuf, "%s~", f);
  56.   unlink(sysbuf);
  57.   if (!link(f, sysbuf)) unlink(f);
  58. }
  59.  
  60. char *strip(str, suf)
  61. char *str, *suf;
  62. {
  63.   char *p1, *p2;
  64.  
  65.   for (p1 = &str[strlen(str)-1], p2 = &suf[strlen(suf)-1];
  66.     (p1 >= str && p2 >= suf) && (*p1 == *p2);
  67.     --p1, --p2);
  68.  
  69.   if (p2 < suf)
  70.   {
  71.     *(p1+1) = '\0';
  72.     return str;
  73.   } else
  74.     return NULL;
  75. }
  76.  
  77. char *mksuff(name, suff)
  78. char *name, *suff;
  79. {
  80.   char *temp;
  81.  
  82.   temp = (char *)malloc(strlen(name)+strlen(suff)+1);
  83.   strcpy(temp, name);
  84.   strcat(temp, suff);
  85.   return temp;
  86. }
  87.